package atri.service.Impl;

import atri.mapper.RecommendMapper;
import atri.model.Recommend;
import atri.service.RecommendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@Repository

public class RecommendServiceImpl extends ServiceImpl<RecommendMapper, Recommend> implements RecommendService {
    @Autowired
    RecommendMapper recommendMapper;

    @Override
    public List<Recommend> recommends_content(String content,int pages) {
        PageHelper.startPage(pages, 6);
        List<Recommend> recommends = recommendMapper.find_by_content(content);
        return recommends;
    }
    @Override
    public List<Recommend> recommends_list(int pages) {
        PageHelper.startPage(pages, 6);
        List<Recommend> recommends = recommendMapper.find_recommends();
        return recommends;
    }

    @Override
    public List<Recommend> recommends_title(String title,int pages) {
        PageHelper.startPage(pages,6 );
        List<Recommend> recommends = recommendMapper.find_by_title(title);
        return recommends;
    }

    @Override
    public List<Recommend> recommends_user(int id) {
        List<Recommend> recommends = recommendMapper.find_user_recommends(id);
        return recommends;
    }

    @Override
    public List<Recommend> recommends_hot() {
        List<Recommend> recommends = recommendMapper.find_hot_10();
        return recommends;
    }

    @Override
    public int delete_under_recommends(int f_id) {
        int a = 0;
        a = recommendMapper.delete_under_recommends(f_id);
        return a;
    }

    @Override
    public Recommend recommends_by_id(int id) {
        Recommend recommend = recommendMapper.find_by_id_new(id);
        return recommend;
    }

    @Override
    public List<Recommend> recommends_category(String category) {
        List<Recommend> recommends = recommendMapper.find_by_category(category);
        return recommends;
    }

    @Override
    public Boolean delete_by_user_id(int id) {
        Boolean a = recommendMapper.delete_by_user_id(id);
        return a;
    }

    @Override
    public Boolean add_view(int id) {
        Boolean a = recommendMapper.add_view(id);
        return a;
    }

    @Override
    public int find_new_id() {
        return recommendMapper.find_new_id();
    }
}
